home *** CD-ROM | disk | FTP | other *** search
- Path: news.crystalball.com!news
- From: Larry Weiss <lfw@oc.com>
- Newsgroups: comp.lang.c
- Subject: Re: Tradition or what?
- Date: Tue, 05 Mar 1996 09:25:05 -0600
- Organization: crystalball.com
- Message-ID: <313C5CD1.1209@oc.com>
- References: <4g0elg$mdr@redstone.interpath.net> <4h0bbo$c0q@fohnix.metronet.com> <4h7ce0$ojd@news.interpath.net> <4h85sm$lm0@texas.nwlink.com> <danpop.825961872@rscernix>
- NNTP-Posting-Host: external.oc.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Dan Pop wrote:
- >
- > In <4h85sm$lm0@texas.nwlink.com> Teresa Reiko <tjr19@mail.nwlink.com> writes:
- > >Here are the three worst Microsoft coding rules, in my opinion at least:
- > >Every line of code must contain a comment.
- > >Any number greater than 2 must be a named constant.
- > >No procedure may be longer than 25 lines.
-
-
- > Actually, the second rule is quite good (except that '2' should be replaced
- > by '1' :-) Magic constants embedded in the code are a huge nuisance
- > for maintenability. If you have to change an explicit (aka magic) constant
- > in a piece of code, how can you be sure that you aren't going to break
- > anything? By changing a macro definition, you _know_ that you won't
- > break anything, because all the dependencies of that macro will be
- > automatically taken care of by the compiler (and your "make" utility).
-
- I agree that there are good uses for giving a literal a name, and using
- that name instead of repeated usage of the literal, but to make a
- mandate that even if the literal were referenced only once you must give
- it a name would seem too extreme.
-
- In the environment of named literals, I must always refer back to the
- mapping. Now you would say, fine, just deal with the abstraction and
- not the actual value, but what I lose is the ability to readily make
- comparisons to other literal values when they just have names. I can't
- readily see the proportions and other relative associations that are
- usually there in the code. I no longer have an immediate grasp of
- the qualities of "small" or "large" or maybe "unusually large" if all
- is hidden in an abstract, one string fits all name. When there are errors
- in the #define of the literal's name, these can be very hard to detect,
- as they are hidden away in the header file.
-
- Anyway, I'm just saying teach the concept of named literals and then let
- the programmer make the decision on a case by case basis.
-